 using System;

namespace FlightAnalyzer {

	public class ScheduleAnalyzer {
		public string flightNum { get; set; }
		public string origin { get; set; }
		public string destination { get; set; }
    // weatherOrigin is the weather affects at point of origin.
		public int weatherOrigin { get; set; }
    // weatherDest is the weather affects at point of destination.
		public int weatherDest { get; set; }
    // flightSchedule is the minutes the flight is delayed form the schedule.
		public int flightSchedule { get; set; }
    // takeoffTime is the amount of minutes the time deviates from the schedule.
		public int takeoffTime { get; set; }
    // arrivalTime is the amount of minutes the time deviates from the schedule.
		public int arrivalTime { get; set; }

		public ScheduleAnalyzer (string newFlightNum, string newOrigin, string newDest) {
			flightNum = newFlightNum;
			origin = newOrigin;
			destination = newDest;
			weatherOrigin = 0;
			weatherDest = 0;
			flightSchedule = 0;
			takeoffTime = 0;
			arrivalTime = 0;
			historicalTakeoffTime = retrieveHistoricalTakeoffTime ();
			historicalArrivalTime = retrieveHistoricalArrivalTime ();
		}

	 	public int getTakeoffTime() {
			// This method will return 0 if take off time is not altered from the
			// original flight schedule. Otherwise it will return a positive or
			// negative number, depending on if the flight is targeted to leave
			// early (negative number) or late (positive number). -1 is a special
			// case which means the flight is targeted for cancellation.

			int timeFactor = 0;
			
			// weatherOrigin and flightSchedule should be set before this function
			// this code is executed.
			timeFactor = computeWeatherAffects (weatherOrigin);
			if (timeFactor == -1 || flightSchedule == -1) {
				return -1;
			}
			timeFactor = timeFactor + flightSchedule;
			takeoffTime = timeFactor;
			return timeFactor;
		}

		public int getArrivalTime() {
			// This method will return 0 if landing time is not altered from the
			// original schedule. Otherwise a positive or negative number will be
			// returned, which represents the number of minutes the flight will
			// deviate from the original schedule. -1 is a special case that means
			// their was an error.

			int timeFactor = 0;

			// weatherDest and flightSchedule must be set before this code is run.
			timeFactor = computeWeatherAffects (weatherDest);
			if (timeFactor == -1 || flightSchedule == -1) {
				return -1;
			}
			timeFactor = timeFactor + flightSchedule + takeoffTime;
			arrivalTime = timeFactor;
			return timeFactor;
		}

		public int computeWeatherAffects(int intensity) {
			// intensity is rated from 0 to 6, with 6 being the worst weather condition.
			// If minutes is set to -1, it means the flight is targeted for cancellation.
			int minutes = 0;

			switch (intensity) {
			case 0:
				minutes = 0;
				break;
			case 1:
				minutes = 20;
				break;
			case 2:
				minutes = 30;
				break;
			case 3:
				minutes = 45;
				break;
			case 4:
				minutes = 60;
				break;
			case 5:
				minutes = 120;
				break;
			case 6:
				minutes = -1;
				break;
			}
			return minutes;
		}

		public static void Main() {
			ScheduleAnalyzer scheduler = new ScheduleAnalyzer("TestFlight114", "Dallas", "New York");
			scheduler.weatherDest = 1;
			scheduler.flightSchedule = 30;
			scheduler.weatherOrigin = 1;
			scheduler.getTakeoffTime();
			scheduler.getArrivalTime();

			Console.WriteLine("The projected take off time is {0} minutes from the scheduled time.", scheduler.takeoffTime);
			Console.WriteLine("The projected landing time is {0} minutes from the scheduled time.", scheduler.arrivalTime);

		}
	}
}

